using System.Collections;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;

public class SingltonMono<T> : MonoBehaviour where T : MonoBehaviour
{
    protected static T instance;
    public static T Instance => instance;

    protected virtual void Awake()
    {
        instance = this as T;
    }

    public Coroutine DelayAction(float delay, UnityAction delayAction)
    {
        return StartCoroutine(DelayActionIE(delay, delayAction));
    }

    IEnumerator DelayActionIE(float delay, UnityAction delayAction)
    {
        yield return new WaitForSeconds(delay);
        delayAction?.Invoke();
    }
    protected void CloseApplication()
    {
#if UNITY_EDITOR
        EditorApplication.isPlaying = false;
#else 
        Application.Quit();
#endif
    }
}
